home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LT_LabelWidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-21  |  679 b   |  42 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. LONG LIBENT
  10. LT_LabelWidth(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
  11. {
  12.     if(handle)
  13.     {
  14.         LONG len;
  15.         LONG cnt;
  16.  
  17.         cnt = 0;
  18.         len = 0;
  19.  
  20.         while(label[len])
  21.         {
  22.             if(label[len] == '_')
  23.                 cnt += TextLength(&handle -> RPort,"_",1);
  24.  
  25.             len++;
  26.         }
  27.  
  28.         return(TextLength(&handle -> RPort,label,len) - cnt);
  29.     }
  30.     else
  31.         return(0);
  32. }
  33.  
  34. LONG LIBENT
  35. LT_LabelChars(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
  36. {
  37.     if(handle)
  38.         return((LT_LabelWidth(handle,label) + handle -> GlyphWidth - 1) / handle -> GlyphWidth);
  39.     else
  40.         return(0);
  41. }
  42.